using System;
using System.Collections.Generic;
using SouthernLand.Common.DAL.Articles;
using SouthernLand.Common.Untilities;

namespace SouthernLand.Common.BOL.Articles
{
    public class ArticleCategory
    {
        #region Public Properties

        public Int32 CateID { get; set; }

        public String AppKey { get; set; }

        public String CateName { get; set; }

        public String CateName_en { get; set; }

        public String CateDesc { get; set; }

        public String ImageUrl { get; set; }

        public Int32 CateOrder { get; set; }

        public Int32 ParentID { get; set; }

        #endregion

        #region public static Methods

        public static List<ArticleCategory> GetArticleCategoryHomePageByParentID(Int32 parentId)
        {
            var db = new ArticleCategoryDAL();
            return db.GetArticleCategoryHomePageByParentID(parentId);
        }


        public static int Insert(ArticleCategory obj)
        {
            var db = new ArticleCategoryDAL();
            return db.Insert(obj);
        }

        public static bool Update(ArticleCategory obj)
        {
            var db = new ArticleCategoryDAL();
            return db.Update(obj);
        }

        public static bool Delete(Int32 cateId)
        {
            if (cateId == ConvertUtility.ToInt32(EnumCategory.News))
                return false;

            if (cateId == ConvertUtility.ToInt32(EnumCategory.RootCategory))
                return false;

            if (cateId == ConvertUtility.ToInt32(EnumCategory.Bancanbiet))
                return false;


            if (cateId == ConvertUtility.ToInt32(EnumCategory.TinTucOnline))
                return false;


            if (cateId == ConvertUtility.ToInt32(EnumCategory.VanHoaGiaiTri))
                return false;

            var db = new ArticleCategoryDAL();
            return db.Delete(cateId);
        }

        public static ArticleCategory GetArticleCategoryByID(Int32 cateId)
        {
            var db = new ArticleCategoryDAL();
            return db.GetArticleCategoryByID(cateId);
        }

        public static string GetCateNameByCateID(Int32 cateId)
        {
            try
            {
                ArticleCategory obj = GetArticleCategoryByID(cateId);
                return (Globals.LangVietNam()) ? obj.CateName : obj.CateName_en;
            }
            catch
            {
                return "";
            }
        }


        //Get All ArticleCategory
        public static List<ArticleCategory> GetAllArticleCategory(int pageIndex, int pageSize)
        {
            var db = new ArticleCategoryDAL();
            return db.GetAllArticleCategory(pageIndex, pageSize);
        }

        // Get Count All records of Table  ArticleCategory
        public static int GetCountArticleCategory()
        {
            var db = new ArticleCategoryDAL();
            return db.GetCountArticleCategory();
        }


        public static Int32 GetAutoCateID()
        {
            var db = new ArticleCategoryDAL();
            return db.GetAutoCateID();
        }


        public static List<ArticleCategory> GetArticleCategoryByParentID(Int32 parentId)
        {
            var db = new ArticleCategoryDAL();
            return db.GetArticleCategoryByParentID(parentId);
        }

        #endregion
    }
}